/**
 * 
 */
package com.haizhi.user.controller;

import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.haizhi.bean.TbUser;
import com.haizhi.service.BaseService;
import com.haizhi.service.UserService;
import com.haizhi.service.impl.UserServiceImpl;
import com.haizhi.util.MyMapBuilder;

/**
 * @author jiangjintai
 *
 */
@Controller
@RequestMapping("/test")
public class TestController {
	private static String s = "123";
	@Autowired
	UserService userService;
	@RequestMapping("")
	@ResponseBody
	public Map<String,String> test(TbUser tbUser){
		tbUser.setUserAccount("123");
		tbUser.setUserFansCount(0);
		tbUser.setUserFollowerCount(0);
		tbUser.setUserCollectionCount(0);
		tbUser.setUserRegisterTime(new Date());
		tbUser.setUserStatus(1);
		this.userService.save(tbUser);
		return new HashMap<String,String>();
		
	}
	
	@RequestMapping("/123")
	public String test2(){
		List<TbUser> u  = this.userService.findAll();
		for(TbUser u2:u){
			System.out.println(u2);
		}
		return null;
	}
	
	@RequestMapping("/callback")
	public ResponseEntity<Map<String,Object>> callback(HttpServletRequest request) throws IOException{
		File file = new File(request.getServletContext().getRealPath("/"),"测试成功.txt");
		if(!file.exists()){
			file.createNewFile();
		}
		System.out.println("反馈成功");
		return new ResponseEntity<>(MyMapBuilder.buildSuccessMap("获取成功"),HttpStatus.OK);
	}
	
	public static String getS(){
		String s1 = "123";
		return s1;
	}
	
	
	
	public static void main(String[] args){
		System.out.println(new Object());
		System.out.println(getS()==BbsController.s);
		System.out.println(s.equals(getS()));
	}
}
